var util = require('../../../utils/util.js');
var api = require('../../../config/api.js');
var app = getApp();
/** 
Page({
  data: {
    longitude: '116.481451',
    latitude: '40.006822',
    polyline: [{
      points: [{
        longitude: '116.481451',
        latitude: '40.006822'
      }, {
        longitude: '116.487847',
        latitude: '40.002607'
      }, {
        longitude: '116.496507',
        latitude: '40.006103'
      }],
      color: "#FF0000DD",
      width: 3,
      dottedLine: true
    }],
  },
  onLoad: function (options) {

  },
  onReady: function () {

  },
  onShow: function () {

  },
  onHide: function () {
    // 页面隐藏

  },
  onUnload: function () {
    // 页面关闭
  },
  
})
*/
Page({
  data: {
    polyline: [{
      points: [{
        longitude: '116.481451',
        latitude: '40.006822'
      }, {
        longitude: '116.487847',
        latitude: '40.002607'
      }, {
        longitude: '116.496507',
        latitude: '40.006103'
      }, {
        longitude: '116.507847',
        latitude: '40.002607'
      }, {
        longitude: '116.516507',
        latitude: '40.006103'
      }],
      color: "#FF0000DD",
      width: 3,
      dottedLine: true
    }],
    Height: 0,
    scale: 15,
    longitude: '116.496507',
    latitude: '40.006103',
      
    markers: [],
    controls: [{
      id: 1,
      iconPath: '/pages/img/jian.jpg',
      position: {
        left: 320,
        top: 100 - 50,
        width: 20,
        height: 20
      },
      clickable: true
    }, 　　 
    {
      id: 2,
      iconPath: '/pages/img/jia.jpg',
      position: {
        left: 340,
        top: 100 - 50,
        width: 20,
        height: 20
      },
      clickable: true
    }],
    circles: []
  },
  onLoad: function() {
    var _this = this;
    wx.getSystemInfo({
      success: function(res) {　　 //设置map高度，根据当前设备宽高满屏显示
        _this.setData({
          view: {
            Height: res.windowHeight
          }　
        })
      }
    })
    /*
    var i = 0;
    var lo = 116.516507;
    var la = 40.006103;
    var timer = setInterval(function fn() {
      if(i<10){
        var data = {};
        data.longitude = lo + 0.01 + '';
        data.latitude = la + 0.01 + '';
        _this.data.polyline[0].points.push(data);
      }else{
        clearInterval(timer);
      }
    }, 1000);
    */
    /*　　
    wx.getLocation({
      type: 'wgs84', // 默认为 wgs84 返回 gps 坐标，gcj02 返回可用于 wx.openLocation 的坐标
      　　success: function(res) {
        _this.setData({
          latitude: res.latitude,
          　　longitude: res.longitude,
          　　markers: [{
            id: "1",
            　　latitude: res.latitude,
            　　longitude: res.longitude,
            　　width: 50,
            　　height: 50,
            　　iconPath: "/assests/imgs/my.png",
            　　title: "哪里"
          }],
          　　circles: [{
            latitude: res.latitude,
            　　longitude: res.longitude,
            　　color: '#FF0000DD',
            　　fillColor: '#7cb5ec88',
            　　radius: 3000,
            　　strokeWidth: 1
          }]　
        })
      }
    })*/
  },
  regionchange(e) {
    console.log("regionchange===" + e.type)
  },
  　　 //点击merkers
  　　markertap(e) {
    console.log(e.markerId)　　 
    wx.showActionSheet({
      itemList: ["A"],
      　　success: function(res) {
        console.log(res.tapIndex)
      },
      　　fail: function(res) {
        console.log(res.errMsg)
      }　
    })　　
  },
  //点击缩放按钮动态请求数据
  　controltap(e) {
    var that = this;
    console.log("scale===" + this.data.scale)
    if (e.controlId === 1) {　　 // if (this.data.scale === 13) {
      that.setData({
        scale: --this.data.scale
      })　　 // }
    } else {　　 // if (this.data.scale !== 13) {
      that.setData({
        scale: ++this.data.scale
      })　　 // }
    }　
  },
  　
})